//
//  GHDefaultCentView.m
//  12-guhu_weibo
//
//  Created by GHapple on 15-2-1.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "GHDefaultCentView.h"


@interface GHDefaultCentView ()
/**
 *  图标
 */
@property (weak, nonatomic) IBOutlet UIImageView *icon;
/**
 *  描述
 */
@property (weak, nonatomic) IBOutlet UILabel *iconlable;
/**
 *  注册
 */
- (IBAction)regist:(id)sender;
/**
 *  发送
 */
- (IBAction)load:(id)sender;


@property(nonatomic,strong)CADisplayLink *displaylink;

@end

@implementation GHDefaultCentView





- (CADisplayLink *)displaylink{
    if (_displaylink == nil) {
        _displaylink = [CADisplayLink displayLinkWithTarget:self selector:@selector(updata)];
    }
    return _displaylink;
}


- (void)updata{
    self.turnIcon.transform = CGAffineTransformRotate(self.turnIcon.transform, M_PI/150);
}



+(instancetype)defaultCentView{

    return [[[NSBundle mainBundle] loadNibNamed:@"GHDefaultCenterView" owner:nil options:nil]lastObject];

}
//注册

- (IBAction)regist:(id)sender {
    
    if ([self.delegate respondsToSelector:@selector(defaultCenterView:didClickRegister:)]) {
        [self.delegate defaultCenterView:self didClickRegister:sender];

}
}
- (IBAction)load:(id)sender {
    if ([self.delegate respondsToSelector:@selector(defaultCenterView:didClickLogin:)]) {
        [self.delegate defaultCenterView:self didClickLogin:sender];
    }
}
- (void)setLablestring:(NSString *)lablestring{
    _lablestring  =  lablestring;
    self.iconlable.text  = lablestring;
}
- (void)setIconName:(NSString *)iconName{
    _iconName = iconName;
   self.icon.image = [UIImage imageNamed:iconName];
}
/**
 *  开始转盘
 */
- (void)startTurn{
    // 通过定时器来实现不断的旋转
    [self.displaylink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];

}
/**
 *  停止转盘
 */
- (void)stopTurn{
    // 关闭定时器
    [self.displaylink invalidate];
    self.displaylink = nil;
}

@end
